using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class LevelInitialize : MonoBehaviour
{
    [SerializeField] private Transform playerBornPos;
    [SerializeField] private bool refreshPlayer = false;
    [SerializeField] private bool instantiatePlayer = false;
    public bool isKinematic = false;
    void Awake()
    {
        if (PlayerController.GetInstance() != null)
        {
            DestroyImmediate(PlayerController.GetInstance().gameObject);
        }
        if (instantiatePlayer)
        {
            Instantiate(GameManager.GetInstance().playerPrefab, playerBornPos.position, playerBornPos.rotation);
        }
        if (isKinematic)
        {
            PlayerController.GetInstance().GetComponent<Rigidbody2D>().bodyType = RigidbodyType2D.Kinematic;
        } else
        {
            PlayerController.GetInstance().GetComponent<Rigidbody2D>().bodyType = RigidbodyType2D.Dynamic;
        }
        

        if (GameManager.GetInstance().GetHp <= 0 && refreshPlayer)
        {
            PlayerHealth.GetInstance().RefreshPlayerHealth(10);
            PlayerHealth.GetInstance().RefreshPlayerStrength(60);
        }
        if (GameManager.GetInstance().GetStrength <= 0 && refreshPlayer)
        {
            PlayerHealth.GetInstance().RefreshPlayerStrength(60);
        }
    }


}
